﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Telerik.WinControls;
using Telerik.WinControls.UI;
using Pakxel.Data;

namespace Pakxel.SmartLogistic.Admon
{
    public partial class DetalleCxPWorkBench : Telerik.WinControls.UI.RadForm
    {
       private MEDataDataContext DataContext;
       private void SetUpDetalleGridView()
       {
          cxpDetalleGridView.AllowEditRow = false;
          cxpDetalleGridView.AllowAddNewRow = false;
          cxpDetalleGridView.AllowDeleteRow = false;
          cxpDetalleGridView.AutoGenerateColumns = true;

          //GridViewDateTimeColumn colT030Fecha = new GridViewDateTimeColumn("T026FechaIngreso", "T026FechaIngreso");
          //colT030Fecha.HeaderText = "Fecha";
          //colT030Fecha.FormatInfo = new System.Globalization.CultureInfo("es-MX");
          //colT030Fecha.FormatString = "{0:dd/MM/yyyy}";
          //colT030Fecha.Width = 400;

          //GridViewDecimalColumn colT030Anticipo = new GridViewDecimalColumn("T030Anticipo", "T030Anticipo");
          //colT030Anticipo.HeaderText = "Monto";
          //colT030Anticipo.FormatInfo = new System.Globalization.CultureInfo("es-MX");
          //colT030Anticipo.FormatString = "{0:C}";
          //colT030Anticipo.Width = 400;
           
          //try
          //{
          //   //cxpDetalleGridView.Columns.Add(colT030Fecha);
          //   //cxpDetalleGridView.Columns.Add(colT030Anticipo);
             
          //}
          //catch (SystemException se)
          //{
          //   MainApp.WriteExceptionToLog(se);
          //}
       }
       
       public DetalleCxPWorkBench()
        {
            InitializeComponent();
        }

       private void DetalleCxPWorkBench_Load(object sender, EventArgs e)
       {
           DataContext = new MEDataDataContext(WorkBench.ConnectionString);
           SetUpDetalleGridView();
           cxpDetalleGridView.DataSource = DataContext.GetFacturacionCxP(); 
           foreach (GridViewDataColumn col in this.cxpDetalleGridView.Columns)
           {
               col.BestFit();
           }
       }

       private void tsbActualizar_Click(object sender, EventArgs e)
       {
          cxpDetalleGridView.DataSource = DataContext.GetFacturacionCxP();
          foreach (GridViewDataColumn col in this.cxpDetalleGridView.Columns)
          {
             col.BestFit();
          }
       }

       private void tsbVencidas_Click(object sender, EventArgs e)
       {
          cxpDetalleGridView.DataSource = DataContext.GetFacturasVencidasCxP();
          foreach (GridViewDataColumn col in this.cxpDetalleGridView.Columns)
          {
             col.BestFit();
          }
       }
    }
}
